<template>
  <div class="repayment">
<div>

<el-form :inline="true" :model="formInline" class="demo-form-inline">
  <el-form-item label="企业名">
    <el-input v-model="formInline.enterprisename" placeholder="企业名"></el-input>
  </el-form-item>
  <el-form-item label="社会信用代码">
    <el-input v-model="formInline.code" placeholder="****">
      
    </el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onSubmit">查询</el-button>
  </el-form-item>
</el-form>

</div>
<div style="height:500px">
  <el-table
    :data="tableData"
    border
    style="width: 120%">
    <el-table-column
      fixed
      prop="oid"
      label="序号"
      width="50">
    </el-table-column>
    <el-table-column
      prop="enterprisename"
      label="企业名称"
      width="180">
    </el-table-column>
    <el-table-column
      prop="code"
      label="社会信用代码"
      width="250">
    </el-table-column>
    <el-table-column
      prop="overdueamount"
      label="逾期金额"
      width="150">
    </el-table-column>
    <el-table-column
      prop="overterm"
      label="逾期期数"
      width="120">
    </el-table-column>
    <el-table-column
      prop="overdate"
      label="逾期天数"
      width="120">
    </el-table-column>
    <el-table-column
      prop="count"
      label="催收次数"
      width="100">
    </el-table-column>
    
    <el-table-column
      fixed="right"
      label="操作"
      width="180">
      <template slot-scope="scope" style="margin: 0  auto;">
        <el-button type="text" size="small" @click="handleClicks(scope.row)" >新增催收</el-button>
        <el-button type="text" size="small" @click="handleClick(scope.row),dialogVisible = true">申请资产保全</el-button>
       
      </template>
    </el-table-column>
  </el-table>
</div>

  <!-- <div class="block"> -->
    
    <el-pagination 
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[3, 4, 5, 7]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalRecord">
    </el-pagination>
  <!-- </div> -->











<el-dialog
  title="提示"
  :visible.sync="dialogVisible"
  width="30%"
  :before-close="handleClose">
  <span>是进行资产保全申请</span>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false,confirom()">确 定</el-button>
  </span>
</el-dialog>
  </div>
</template>

<script>
export default {
  data () {
    return {
      oids:this.oids,
      pageSize:7,
     dialogVisible: false,
      totalRecord:this.totalRecord,
       currentPage4: 1,
     tableData: [],
      formInline: {
          user: '',
          region: ''
        }
    }
  },
  created(){
      this.init()
  },

  methods:{
     onSubmit() {
        console.log('submit!');
        this.$axios.get("http://localhost:8082/loanmanage/selcetByname", 
        {params: {
            enterprisename:this.formInline.enterprisename,
            code:this.formInline.code
        }}).then(resp=>{
           this.tableData=resp.data.data
          console.log(resp)
        })
      },
     handleSizeChange(val) {
       this.pageSize=val
        console.log(`每页 ${val} 条`);
         this.init();
      },
      handleCurrentChange(val) {
          this.currentPage4=val
        console.log(`当前页: ${val}`);
        this.init();
      },
      handleClick(row){
 console.log(row);
this.oids=row.oid

console.log("oids---"+this.oids);
      },
      confirom(){

 this.$axios
        .get("http://localhost:8082/OverDueCollection/insert", {
          params: {
            
           oids:this.oids
          }
        })
        .then(resp => {
          this.tableData = resp.data.data.beanList;
          this.totalRecord=resp.data.data.totalRecord;
          console.log(resp)
        });
      },
       handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      },
    handleClicks(row) {
      this.$router.push({path:'/collectionrecords',query:{oid:row.oid}});
  
        console.log(row+"----");
      },
    init(){
      this.$axios
        .get("http://localhost:8082/OverDueCollection/repaymentAll", {
          params: {
            
            pageIndex:this.currentPage4,
            pageSize: this.pageSize
          }
        })
        .then(resp => {
          this.tableData = resp.data.data.beanList;
          this.totalRecord=resp.data.data.totalRecord;
          console.log(resp)
        });
    }
  }
}
</script>

<style >
.block{
 position: relative;
 left: 350px;
 top: 200px;


}


</style>